package iam

import (
	"testing"

	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/client/iam"
	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/core/config"
	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/ichain_sdk"
	iam2 "git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/providers/iam"
	"git.cloud.inspur.com/ichain/ichain-sdk-go/test/data"
	"github.com/stretchr/testify/assert"
)

func TestIam(t *testing.T) {
	env := data.GetEnvFromFlag()
	assert.NotNil(t, env)
	sdk, err := ichain_sdk.New(config.FromBuilder(env.SdkBuilder()))
	assert.NoError(t, err)
	defer sdk.Close()
	iamClient, err := iam.New(sdk.Context())
	assert.NoError(t, err)
	// 测试创建身份
	identity, err := iamClient.CreateSigningIdentity(iam2.WithCert(env.ClientCert()),
		iam2.WithPrivateKey(env.ClientPvk()))
	assert.NoError(t, err)
	assert.NotEmpty(t, identity)
}
